var request = require('./request')

function code2Session(code, appid,secret) {
  return request.get("weChat/login",{code,appid,secret})
}

/**
 *  获取医院系统配置
 * @param {编码} code 
 */
function getHosConfig(code) {
  var options = {
    "pageNo": 0,
    "pageSize": 0,
    "queryCondition": "",
    "querySort": "",
    "queryStandardList": [{
      "condition": "EQ",
      "field": "sysCode",
      "value": code
    }],
    "sortList": [],
    "total": 0
  }
  return request.post('sysConfig/getAll', options)
}
/**
 * 获取医院系统配置
 * @param {自定义条件} options 
 */
function getHosConfigs(options) {
  return request.post('sysConfig/getAll', options)
}
/**
 * 获取服务器地址
 */
function getBaseUrl() {
  return request.getBaseUrl()
}
/**
 * 获取门诊/住院医生
 * @param {0 门诊 1 住院 2 急诊} features 
 */
function getDoctorList(features) {
  return request.post("doctor/getDoctorDtoList", features)
}
/**
 * 获取知名科室
 */
function getFamousDeptList() {
  return request.post("dept/getFamousDeptList", "")
}
/**
 * 获取专家信息
 */
function getExpertDoctor() {
  return request.post("doctor/getExpertDoctor", "")
}
/**
 * 获取医生排班
 * @param {条件} options 
 */
function getDoctorSchedulingList(options) {
  return request.post("scheduling/getDoctorSchedulingList", options)
}
/**
 * 获取医生号源
 * @param {参数} params 
 */
function getRegistrationSource(params) {
  return request.post("scheduling/getRegistrationSource", params)
}
/**
 * 创建患者信息
 * @param {患者信息} params 
 */
function createPatient(params){
  return request.post("patient/createPatient",params);
}

/**
 * 获取当前绑定的患者信息
 */
function getBindPatientDtoList(){
  return request.post("patient/getBindPatientDtoList",{});
}
/**
 * 设置默认
 * @param {门诊号} ioNo 
 */
function fitCrtPatient(ioNo){
  return request.post("patient/fitCrtPatient",{ioNo});
}
/**
 * 解绑患者
 * @param {门诊号} ioNo 
 */
function unBindPatient(ioNo){
  return request.post("patient/unBindPatient",{ioNo});
}
/**
 * 绑定患者
 * @param {患者信息} params 
 */
function bindPatient(params){
  return request.post("patient/bindPatient",params);
}
function getIoNo(params){
  return request.post("patient/getIoNo",params);
}

function sendVerifyCode(phoneNumber){
  return request.post("weChat/sendVerifyCode",{phoneNumber:phoneNumber});
}

function getApply(params){
  return request.post("clinicApply/getApply",params);
}

function getApplyResult(applyNo){
  return request.post("clinicApply/getApplyResult",applyNo);
}

function getMainDtoList(params){
  return request.post("prescription/getMainDtoList",params);
}

function charge(params){
  return request.post("prescription/charge",params);
}

function appointment(params){
  return request.post("scheduling/appointment",params);
}

function register(params){
  return request.post("scheduling/register",params);
}

function cancelAppointment(params){
  return request.post("scheduling/cancelAppointment",params);
}

function getAppointRecord(params){
  return request.post("scheduling/getAppointRecord",params);
}

function getRegisterRecord(params){
  return request.post("scheduling/getRegisterRecord",params);
}
module.exports = {
  code2Session, //从中间服务器用code换取用户信息
  getHosConfig, //根据编码获取系统配置
  getHosConfigs, //系统配置
  getBaseUrl, //获取基础url 用于拼接images
  getDoctorList, // 获取门诊/住院医生
  getExpertDoctor, //获取所有专家
  getFamousDeptList, //获取知名科室
  getDoctorSchedulingList, //获取排班
  getRegistrationSource, //获取号源
  createPatient,//创建患者信息
  getBindPatientDtoList,//获取当前的患者信息
  fitCrtPatient,//设置默认
  unBindPatient,//解绑患者
  bindPatient,//绑定患者
  getIoNo,//根据身份证号查询患者门诊号
  sendVerifyCode,//发送验证码
  getApply,//获取单据
  getApplyResult,//获取单据结果
  getMainDtoList,//获取处方信息
  charge,//结算
  appointment,//预约
  register,//挂号
  cancelAppointment,//取消预约
  getAppointRecord,//获取预约记录
  getRegisterRecord,//获取挂号记录
}